While Flash memory is a non-volatile memory, it is prone to data corruption due to power loss that may occur at any unexpected moment and during any operation type that is being carried out by the flash. The problem arises from the fact that power loss may occur at the middle of an operation, such as write data or erase data, when power is restored, it is not possible to know if the last operation before power loss was properly completed or not.
The problem of interrupted flash operation becomes more significant because some flash operations are relatively very long operations, for example, a write operation may last between one to five milliseconds and erase can achieve few hundreds milliseconds.
It should be noted that write operations to flash memory, unlike other memories such as hard-disk or RAM, can only be written as “0”. When it is desired to write “1”, the block should be erased. The erase operation sets all the bits of an erased block to “1” and afterwards all the bits that were previously set to “0” should be re-written.
Some existing flash systems solved the problem by usage of a Uninterruptible Power Supply (UPS) that enables to retain power for at least some milliseconds—the duration that is required to complete a flash write operation and even erase operation, (Typically—the longest operation). However this solution requires a significant hardware addition to the system.
Another solution that refers specifically to a flash-erase operation is disclosed in U.S. Pat. No. 6,977,847 by Lasser et al. However, Lasser solves only the case of power loss during erase while a power loss may corrupt data in any flash operation phase, such as flash data-write. Furthermore Lasser does not solve the case wherein the operation of setting a flag for indicating the status of an operation fails due to power loss.
There is a need for a method and system for enabling to keep safe data managing that guarantees data integrity after power loss that may interrupt any data operation.